/// 在这里注册handler
use crate::error::AppError;
use crate::handlers::ai::{
    CreateAiConfig, CurrentUseAiConfig, DeleteAiConfig, ListAiConfig, SetCurrentAiConfig,
    UpdateAiConfig,
};
use crate::handlers::datasource::{
    AllDsDesc, CreateDsDesc, CreateDsFile, CreateDsServe, ListDatasource, UpdateDsFile,
    UpdateDsServe,
};
use crate::handlers::duck::{LoadDatasource, TableAll};
use crate::handlers::project::{CreateProject, ImportProject, LoadProject, QueryProject};
use crate::routes::payload::Payload;
use crate::routes::response::Response;
use async_trait::async_trait;
use enum_dispatch::enum_dispatch;

/// 路由处理 trait
#[async_trait]
#[enum_dispatch]
pub trait RouteHandler {
    async fn handle(&self, payload: Payload) -> Result<Response, AppError>;
}

/// 处理器枚举
#[enum_dispatch(RouteHandler)]
pub enum Handlers {
    // 项目相关
    CreateProject,
    QueryProject,
    LoadProject,
    ImportProject,
    // 数据源注册
    CreateDsFile,
    CreateDsServe,
    ListDatasource,
    UpdateDsServe,
    UpdateDsFile,
    // 数据源加载
    LoadDatasource,
    TableAll,
    // AI 配置相关
    CreateAiConfig,
    ListAiConfig,
    DeleteAiConfig,
    UpdateAiConfig,
    CurrentUseAiConfig,
    SetCurrentAiConfig,
    // 数据源描述
    AllDsDesc,
    CreateDsDesc,
}
